package com.xyang.demo.dao;

import com.xyang.demo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author Stars-Of-Future-xYang
 * @version 1.0
 * @date 2021/3/18 15:53
 */
@Mapper
public interface UserMapper {

    @Select("select * from t_user where id=#{id}")
    @Results(id = "users",value = {
            @Result(column = "id",property = "id",id = true),
            @Result(column = "username",property = "username"),
            @Result(column = "password",property = "password"),
            @Result(column = "age",property = "age"),
            @Result(column = "phone",property = "phone"),
            @Result(column = "email",property = "email"),
            @Result(column = "is_delete",property = "isDelete"),
            @Result(column = "department_id",property = "departmentId")
    })
    User findById(Integer id);

    @ResultMap("users")
    @Select("select * from t_user")
    List<User> findAll();
    @ResultMap("users")
    @Select("select * from t_user where department_id=#{id}")
    List<User> findByDId(Integer id);

}
